<ix-fieldset
  [title]="'Name and Options' | translate"
  [formGroup]="form"
>
  @if (parent() && !existing()) {
    <ix-textarea
      formControlName="parent"
      [rows]="3"
      [label]="'Parent Path' | translate"
    ></ix-textarea>
  }

  <ix-textarea
    formControlName="name"
    [rows]="3"
    [required]="true"
    [label]="'Name' | translate"
    [tooltip]="helptext.nameTooltip | translate"
  ></ix-textarea>

  @if (!existing()) {
    <ix-select
      formControlName="share_type"
      [label]="'Dataset Preset' | translate"
      [options]="datasetPresetOptions$"
      [required]="true"
    ></ix-select>
  }
</ix-fieldset>

@if (!existing()) {
  <ix-fieldset [formGroup]="datasetPresetForm">
    <div class="preset-container">
      @if (form.value.share_type) {
        <div class="comments">
          @if (form.value.share_type === DatasetPreset.Generic) {
            {{ helptext.preset.generic| translate }}
          }
          @if (form.value.share_type === DatasetPreset.Smb) {
            <div class="smb-comment">
              <div>{{ helptext.preset.smb | translate }}</div>
              <div>{{ helptext.preset.smbDescription | translate }}</div>
            </div>
          }
          @if (form.value.share_type === DatasetPreset.Apps) {
            {{ helptext.preset.apps | translate }}
          }
          @if (form.value.share_type === DatasetPreset.Multiprotocol) {
            {{ helptext.preset.multiprotocol| translate }}
          }
        </div>
      }

      @if (canCreateNfs || canCreateSmb) {
        <div class="controls">
          @if (canCreateNfs) {
            <ix-checkbox
              formControlName="create_nfs"
              [label]="'Create NFS Share' | translate"
            ></ix-checkbox>
          }
          @if (canCreateSmb) {
            <ix-checkbox
              formControlName="create_smb"
              [label]="'Create SMB Share' | translate"
            ></ix-checkbox>
          }
          @if (canCreateSmb && datasetPresetForm.value.create_smb) {
            <ix-input
              formControlName="smb_name"
              [label]="'SMB Name' | translate"
            ></ix-input>
          }
        </div>
      }
    </div>
  </ix-fieldset>
}
